package com.yedean.factory.io;

import cn.hutool.core.lang.Assert;

/**
 * DefaultResourceLoader
 * 
 * 默认的资源加载器
 *
 * @author yedean
 * @date 2022/7/7
 */
public class DefaultResourceLoader implements ResourceLoader{
    
    @Override
    public Resource getResource(String location) {
        Assert.notNull(location,"fucking 没有location拿不到对应的资源");
        //根据location判断要准备哪个资源类返回
        if (location.startsWith(CLASSPATH_PREFIX)){
            return new ClasspathResource(location.substring(CLASSPATH_PREFIX.length()));
        }else {
            return new FileSystemResource(location);
        }
    }
}
